<?php
	require("konf.php");
	 $yhendus=new mysqli($masin, $kasutaja, $parool, $baas);
	if(isSet($_REQUEST["hobune_id"])){
	 $kask=$yhendus->prepare("INSERT INTO treening (hobune_id, treeningu_liik_id, treeningu_aeg, kommentaar) VALUES(?, ?, ?, ?)");
	 $kask->bind_param("ssss", $_REQUEST["hobune_id"], $_REQUEST["treeningu_liik_id"], $_REQUEST["treeningu_aeg"], $_REQUEST["kommentaar"]);
	 $kask->execute();
	 echo $yhendus->error;
	 $yhendus->close();

	 exit();
  }
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Treeningu leht</title>
	</head>
	<body>
	<div class="content">
		<h3>Treeningute lisamine</h3>
		<form action="?">
		<table width="300px" style="min-width:300px;" border="0">
  <tr>
    <th scope="row">Hobuse id:</th>
    <td><input type="int" name="hobune_id" /></td>
  </tr>
  <tr>
    <th scope="row">Treeningu liik:</th>
    <td><input type="text" name="treeningu_liik_id" /></td>
  </tr>
  <tr>
    <th scope="row">Treeningu aeg:</th>
    <td><input type="date" name="treeningu_aeg" /></td>
  </tr>
  <tr>
    <th scope="row">Kommentaar:</th>
    <td><input type="text" name="kommentaar" /></td>
  </tr>
			<tr class="cell">
    <th scope="row"></th>
    <td><img src="images/Add.png" class="icon" style="left:100px; bottom:12px;"/><input type="submit" value="Lisa Treening" class="lisahobu" /></td>
  </tr>
</table>
</form>
		</div>
		
		<?php
			$yhendus->close();
		?>
	</body>
</html>